import { ref } from 'vue'
import { defineStore } from 'pinia'
import type { LoginResponseData } from '@/api/model/model'

// 登录信息类型
interface LoginEmpInfo {
  token?: string;
  user?: LoginResponseData['user'];
}

export const useLoginEmpStore = defineStore('loginEmp', () => {
  const loginEmp = ref<LoginEmpInfo>({})
  const setLoginEmp = (emp: LoginEmpInfo) => { //存入
    loginEmp.value = emp;
  }
  const getLoginEmp = () => { //获取
    return loginEmp.value;
  }
  const clearLoginEmp = () => { //清除
    loginEmp.value = {}
  }
  return { loginEmp, setLoginEmp, getLoginEmp, clearLoginEmp }
}, {persist: true})
